﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OnlineStore.Dal;
using OnlineStore.Bll;

namespace OnlineStore.Gui
{
    public partial class Product : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            DalProduct _DalProduct = new DalProduct();
            bizProduct _bizProduct =  new bizProduct();
            if (Request.QueryString.Get("Type") != null)
            {
                Session["numberItem"] = _DalProduct.NumberItem(Request.QueryString.Get("Type"));
                mainlist.DataSource = _bizProduct.Search(Request.QueryString.Get("Type"), Request.QueryString.Get("Page"));
            }
            else
            {
                mainlist.DataSource = _DalProduct.Search();
                Session["numberItem"] = _DalProduct.NumberItem();
            }
            
            mainlist.DataBind();
            if (Session["user"] != null)
            {
                HL_tab_login.NavigateUrl = "/gui/Account.aspx";
                HL_tab_login.Text = ((tbCustomer)Session["user"]).Username;
                HL_tab_Logout.Visible = true;
            }
            ListCartRight.DataSource = (List<bizCart>)Session["cart"];
            ListCartRight.DataBind();
            lb_Sum.Text = String.Format("{0:0,0 VNĐ}", bizCart.SumAllList((List<bizCart>)Session["cart"]));
            lb_Sum_product.Text = String.Format("{0:0,0 VNĐ}", bizCart.SumAllList((List<bizCart>)Session["cart"]));
        }
    }
}